﻿using System.ComponentModel;
using System.Collections.ObjectModel;
using DataBases;

namespace SlXnaApp1.ViewModel
{
    public class StatisticsViewModel : INotifyPropertyChanged
    {
        private ObservableCollection<ScoreSet> _scoreSets;
        public ObservableCollection<ScoreSet> ScoreSets
        {
            get { return _scoreSets; }
            set { _scoreSets = value; RaisePropertyChanged("ScoreSets"); }
        }

        public StatisticsViewModel()
        {
            ScoreSets = new ObservableCollection<ScoreSet>(DBHelper.GetScoreSets());
        }

        public void ResetScore()
        {
            DBHelper.DeleteDatabase();
            DBHelper.CreateDatabase();
            ScoreSets = new ObservableCollection<ScoreSet>(DBHelper.GetScoreSets());
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

    }
}
